/* -----------------------------------------------------------------------
 * Paul Cohen
 * CS 362, Summer 2014
 * Assignment 3
 *
 * cardtest3.c - testing Dominion's Salvager card
 * 
 * -----------------------------------------------------------------------
 */

#include "cardtest3.h"
#include "dominion.h"
#include "dominion_helpers.h"
#include "rngs.h"
#include <string.h>
#include <stdio.h>

int card_test3()
{
	int seed = 1000;
	int numPlayers = 2;
	int oldBuys = 0;
	int oldCoins = 0;
	int oldPlayedCardCount = 0;
	int successes = 0;

	int k[10] = {adventurer, council_room, feast, gardens, mine, remodel, smithy, village, baron, great_hall};

	struct gameState g;
	initializeGame(numPlayers, k, seed, &g);

	printf("\nCard Test 3: Salvager\n------------\n");  

	oldBuys = g.numBuys;
	oldCoins = g.coins;
	oldPlayedCardCount = g.playedCardCount;
	g.hand[0][2] = duchy;

	// test with Duchy card
	cardEffect(salvager, 2, 0, 0, &g, 1, 0);
	if (g.numBuys == 2)
		successes++;
	else
		printf("Test failed - buys not updated correctly.\n");
	if (g.coins == oldCoins + 5)
		successes++;
	else
		printf("Test failed - coins not updated correctly.\n");

	if (g.playedCardCount == oldPlayedCardCount + 1)
		successes++;
	else
		printf("Test failed - Salvager card not discarded correctly.\n");


	printf("Salvager tests completed!\n");
    printf("%d out of 3 tests successful.\n", successes);

	return 0;
}